	@include('admin.head')
	<div class="container">
		<div class="row">
			@include('admin.side')
			<div class="col-md-10" id="content-wrapper">

				<div class="row">
					<div class="col-xs-12">
						<div class="main-box">
							<h2>Tabs</h2>
							<div class="tabs-wrapper">
								<ul class="nav nav-tabs">
									<li class="active"><a href="#tab-details" data-toggle="tab">项目详情</a></li>
									<li class=""><a href="#tab-progress" id="progress" data-toggle="tab">项目进度</a></li>
								</ul>
								<div class="tab-content">
									<div class="tab-pane fade active in" id="tab-details">
										<div class="main-box clearfix">
											<div class="clearfix">
												<h2 class="pull-left">项目详情</h2>
											</div>
											<div class="panel panel-default">
												<div class="panel-body">
												  	<div class="row">
												  	</div>
												  	<div class="form-horizontal">
														<div class="form-group">
															<label class="col-xs-4 control-label no_padding_top ">项目名称:</label>
															<div class="col-xs-5 uc_value _left" id="name">
															</div>
														</div>
														<div class="form-group">
															<label class="col-xs-4 control-label no_padding_top ">投资规模（万元）:</label>
															<div class="col-xs-5 uc_value _left" id="price">
															</div>
														</div>
															<div class="form-group">
															<label class="col-xs-4 control-label no_padding_top ">投资模式:</label>
															<div class="col-xs-5 uc_value _left" id="project_types">
															</div>
														</div>


														<div class="form-group">
															<label class="col-xs-4 control-label no_padding_top ">节能效率:</label>
															<div class="col-xs-5 uc_value _left" id="save_effect">
															</div>
														</div>

														<div class="form-group">
															<label class="col-xs-4 control-label no_padding_top ">项目启动时间:</label>
															<div class="col-xs-5 uc_value _left" id="start_time">
															</div>
														</div>
														<div class="form-group">
															<label class="col-xs-4 control-label no_padding_top ">项目结束时间:</label>
															<div class="col-xs-5 uc_value _left" id="end_time">
															</div>
														</div>

														<div class="form-group">
														    <label class="col-xs-4 control-label no_padding_right no_padding_top">省:</label>
														    <div class="col-xs-5 uc_value _left" id="province">

															</div>

													    </div>

													    <div class="form-group">
													        <label class="col-xs-4 control-label no_padding_right no_padding_top">市:</label>
													        <div class="col-xs-5 uc_value _left" id="city">

														    </div>

													    </div>

													    <div class="form-group">
														     <label class="col-xs-4 control-label no_padding_right no_padding_top">区:</label>
														     <div class="col-xs-5 uc_value _left" id="area">

															 </div>

													    </div>


													    <div class="form-group">
															<label class="col-xs-4 control-label no_padding_top ">详细地址:</label>
															<div class="col-xs-5 uc_value _left" id="address">
															</div>
														</div>

														<div class="form-group">
															<label class="col-xs-4 control-label no_padding_top ">是否资产化:</label>
															<div class="col-xs-5 uc_value _left" id="is_request_assets">
															</div>
														</div>
														<div class="form-group">
															<label class="col-xs-4 control-label no_padding_top ">是否申请奖励:</label>
															<div class="col-xs-5 uc_value _left" id="is_request_award">
															</div>
														</div>
														<div class="form-group">
															<label class="col-xs-4 control-label no_padding_top ">是否申请补贴:</label>
															<div class="col-xs-5 uc_value _left" id="is_request_subsidy">
															</div>
														</div>
														<div class="form-group">
															<label class="col-xs-4 control-label no_padding_top ">是否申请退税:</label>
															<div class="col-xs-5 uc_value _left" id="is_request_rebate">
															</div>
														</div>
														<div class="form-group">
															<label class="col-xs-4 control-label no_padding_top">项目图片:</label>
															<div class="col-md-5 uc_value no_padding_left" id="image">
															</div>

														</div>

														<div class="form-group">
													        <label class="col-xs-4 control-label no_padding_right no_padding_top">应用主体:</label>
													        <div class="col-xs-5 uc_value _left" id="main_body">

															</div>

													    </div>
													    <div class="form-group">
													        <label class="col-xs-4 control-label no_padding_right no_padding_top">应用领域:</label>
													        <div class="col-xs-5 uc_value _left" id="project_domain">

															</div>

													    </div>
													    <div class="form-group">
													        <label class="col-xs-4 control-label no_padding_right no_padding_top">节能技术:</label>
													        <div class="col-xs-5 uc_value _left" id="project_tech">

															</div>

													    </div>
													    <div class="form-group">
													        <label class="col-xs-4 control-label no_padding_right no_padding_top">使用的设备:</label>
													        <div class="col-xs-5 uc_value _left" id="use_device">

															</div>

													    </div>
													    <div class="form-group">
													      	<label class="col-xs-4 control-label no_padding_right no_padding_top">使用的技术:</label>
													      	<div class="col-xs-5 uc_value _left" id="use_tech">

															</div>

													    </div>

													     <div class="form-group">
													        <label class="col-xs-4 control-label no_padding_right no_padding_top">节能需求:</label>
													        <div class="col-xs-5 uc_value _left" id="save_require">
															</div>

													    </div>
														<div class="form-group">
													        <label class="col-xs-4 control-label no_padding_right no_padding_top">项目简介:</label>
													        <div class="col-xs-5 uc_value _left" id="description">

															</div>

													    </div>
													    <div class="form-group">
													        <label class="col-xs-4 control-label no_padding_right no_padding_top">项目的主要内容:</label>
													        <div class="col-xs-5 uc_value _left" id="content">
														    </div>
													    </div>

										    		    <div class="form-group">
										    	      		<label for="select" class="col-xs-4 control-label no_padding_right">审核状态:</label>
										    		      	<div class="col-xs-2">
										    		        <select class="form-control input_size" name="verify_state">
										    		          <option value="0">待审核</option>
										    		          <option value="1">审核通过</option>
										    		          <option value="2">审核不通过</option>
										    		        </select>
										    		      </div>
										    		      <div class="col-xs-3 no_padding_both">
										    		      	<button class="btn btn-primary" id="audit">提交</button>
										    		      </div>
										    	    	</div>

													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="tab-pane fade" id="tab-progress">
										<div class="main-box clearfix">
											<div class="clearfix">
												<h2 class="pull-left">项目进度</h2>
											</div>
											<div class="panel panel-default">
												<div class="panel-body">
													<div class="form-horizontal">

													<div class="form-group">
													  <label class="col-xs-4 control-label no_padding_right">项目进度时间:</label>
													  <div class="col-xs-4">
													    <input class="form-control input_size date-time-picker" readonly name="progress_time" autocomplete="of" placeholder="" type="text">
													  </div>
													</div>

													<div class="form-group">
												      <label for="textArea" class="col-xs-4 control-label no_padding_right">项目进度内容:</label>
												      <div class="col-xs-4">
												        <textarea class="form-control text_size" name="content" rows="3" id="textArea"></textarea>
												        <span class="help-block"></span>
												      </div>
												    </div>
												    <div class="col-xs-12 no_padding_both text-center">
												    	<input type="hidden" name="prg_id" value="">
												    	<button class="btn btn-primary" type="button" id="addProgress">提交</button>
												    </div>
											      	<table class="table table-striped table-hover text-center table_marginTop">
											    	  <thead>
											    	      <td><b>项目进度时间</b></td>
											    	      <td><b>项目进度内容</b></td>
											          	  <td><b>操作</b></td>
											    	  </thead>
											    	  <tbody id="progressList">
											    	  </tbody>
											    	</table>
												</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

	@include("admin.footer")
	@include("admin.common")
</body>

<script type="text/html" id="progressTeml">
{%each list as value index}
<tr>
  <td>{%value.progress_time}</td>
  <td>{%value.content}</td>
  <td>
  	<button class="btn btn-primary doEdit" prg_id="{%index}" title="编辑">
  		<i class="fa fa-pencil-square-o"></i>
  	</button>
  	<button href="#" class="btn btn-primary doDelete" prg_id="{%value.id}" title="删除">
  		<i class="fa fa-eye"></i>
  	</button>
  </td>
</tr>
{%/each}
</script>

<script type="text/javascript">
var url = "<%url('admin')%>/";
if("<%Input::has('pid')%>"){
	var pid = "<%Input::get('pid')%>";
	$.get(url + "project/get_detail", {pid :pid},function(data){
		if(data.success){
			var data = data.data;
			$("#name").html(data.name);
			$("#price").html(data.investment_scale);
			$("#project_types").html(data.investment_type.name);
			$("#save_effect").html(data.efficiency);
			$("#start_time").html(data.start_time);
			$("#end_time").html(data.end_time);
			$("#province").html(data.province.area_name);
			$("#city").html(data.city.area_name);
			$("#area").html(data.area.area_name);
			$("#address").html(data.address);

			if( data.is_request_assets == 0){
				$("#is_request_assets").html("否");
			}else{
				$("#is_request_assets").html("是");
			}

			if( data.is_request_award == 0){
				$("#is_request_award").html("否");
			}else{
				$("#is_request_award").html("是");
			}

			if( data.is_request_subsidy == 0){
				$("#is_request_subsidy").html("否");
			}else{
				$("#is_request_subsidy").html("是");
			}

			if( data.is_request_rebate == 0){
				$("#is_request_rebate").html("否");
			}else{
				$("#is_request_rebate").html("是");
			}

			$("#tab-details #content").html(decodeURIComponent(data.content));

			$.each(data.main_body, function(k, v){
				$("#main_body").append(v.main_body.name + " ");
			})
			$.each(data.project_domain, function(k,v){
				$("#project_domain").append(v.domain.cate_name + " ");
			})
			$.each(data.project_tech, function(k,v){
				$("#project_tech").append(v.tech.cate_name + " ");
			})
			$("#save_require").html(data.save_require);
			$("#description").html(data.description);
			$.each(data.use_device, function(k,v){
				$("#use_device").append(v.device.name + " ");
			})

			$.each(data.use_tech, function(k,v){
				$("#use_tech").append(v.technology.tech_name + " ");
			})
			$("select[name='verify_state']").val(data.verify_state);

			if(data.image){
				$("#image").html('<img src="<%url("images")%>/'+data.uid+'/<%env("PROJECT_DIR")%>/'+data.image+'" width="100">');
			}
		}

	})
}


$("#audit").click(function(){
	var state = $("select[name='verify_state']").val();
	$.post("audit", {pid : pid, state : state}, function (data){
		if(data.success)
		{
			success("", "修改成功");
			setTimeout(function(){
				window.location.href="../project";
			}, 2000)
		}
	})
})
var loadProgress = true;
var progress;
var purl = "add_progress";
$("#progress").click(function(){
	if(loadProgress){
		$.get("get_Progress", {pid : pid}, function (data){
			if(data.success){
				progress = data.data;
				var html = template("progressTeml", {list : data.data});
				$("#progressList").html(html);
				loadProgress = false;
				$(".doEdit").bind("click", function(){
					editProgress($(this));
				})

				$(".doDelete").bind("click", function(){
					delProgress($(this));
				})

			}
		})
	}
})

function editProgress(_this){
	var prg_id = _this.attr("prg_id");
	$("#tab-progress input[name='progress_time']").val(progress[prg_id].progress_time);
	$("#tab-progress input[name='prg_id']").val(progress[prg_id].id);
	$("#tab-progress textarea[name='content']").val(progress[prg_id].content);
	purl = "update_progress";
}

function delProgress(_this){
	var prg_id = _this.attr("prg_id");
	confirm("", "确定要删除吗?", "warning", function (data){
		if(data == 1){
			$.post("delete_progress", {prg_id : prg_id, project_id : pid}, function (data){
				if(data.success){
					progress = data.data;
					var html = template("progressTeml", {list : data.data});
					$("#progressList").html(html);
					$(".doDelete").unbind("click");
					$(".doDelete").bind("click", function(){
						delProgress($(this));
					})
					success("", "删除成功");
				}
			})
		}
	})
}


$("#addProgress").click(function(){
	var progress_time = $("#tab-progress input[name='progress_time']").val();
	var content = $("#tab-progress textarea[name='content']").val().trim();
	var prg_id = $("#tab-progress input[name='prg_id']").val();
	if(progress_time == ''){
		warning("项目进度时间不能为空");
		return;
	}
	if(content == ''){
		warning("项目进度内容不能为空");
		return;
	}
	$.post(purl, {progress_time : progress_time, content : content, project_id : pid, prg_id : prg_id}, function (data){
		if(data.success){
			progress = data.data;
			var html = template("progressTeml", {list : data.data});
			$("#progressList").html(html);
			$("#tab-progress input[name='progress_time']").val('');
			$("#tab-progress input[name='prg_id']").val('');
			$("#tab-progress textarea[name='content']").val('');
			$(".doEdit").unbind("click");
			$(".doEdit").bind("click", function(){
				editProgress($(this));
			})

			$(".doDelete").unbind("click");
			$(".doDelete").bind("click", function(){
				delProgress($(this));
			})
			purl = "add_progress";
			success("", "提交成功!");
		}

	})


})




</script>
</html>